<?php
$_DBSite = "Master";
include($_SERVER["DOCUMENT_ROOT"]."/db.inc.php");
$intOldBT = "1";
$intNewBT = "28";

$strSQL= "select * from `bet_Commission` where Bet_Type = ".$intOldBT;
if(!$RS = @PMA_mysql_query($strSQL, $_ConnMaster)){
	$GLOBALS["errorhidden"] = "Find Data Error!";
	$GLOBALS["errorhidden"] = "SQL: ".$strSQL.", \nError: ".PMA_mysql_error($_ConnMaster).", \nLine: ".__LINE__.", \nPage: ".__FILE__;
	include($_SERVER["DOCUMENT_ROOT"]."/error.php");
	exit();
}

if(@PMA_mysql_num_rows($RS) == 0){
	$GLOBALS["errorhidden"] = "Can not Find Data!!";
	$GLOBALS["errorhidden"] = "SQL: ".$strSQL.", \n\nLine: ".__LINE__.", \nPage: ".__FILE__;
	include($_SERVER["DOCUMENT_ROOT"]."/error.php");
	exit();
}

while($Rows = PMA_mysql_fetch_object($RS)){
	$strSQL = "select ID from `bet_Commission` where Bet_Type = ".$intNewBT." and MemID = ".$Rows -> MemID." and Gamble_Type  = ".$Rows -> Gamble_Type;
	if(!$subRS = @PMA_mysql_query($strSQL, $_ConnMaster)){
		$GLOBALS["errorhidden"] = "Find Data Error!";
		$GLOBALS["errorhidden"] = "SQL: ".$strSQL.", \nError: ".PMA_mysql_error($_ConnMaster).", \nLine: ".__LINE__.", \nPage: ".__FILE__;
		include($_SERVER["DOCUMENT_ROOT"]."/error.php");
		exit();
	}
	if(@PMA_mysql_num_rows($subRS) > 0)continue;
	$strSQL = "insert into `bet_Commission`(Bet_Type, MemID, Gamble_Type, Commission) values(".$intNewBT.", ".$Rows -> MemID.", ".$Rows -> Gamble_Type.", '".$Rows -> Commission."')";
	PMA_mysql_query($strSQL, $_ConnMaster);
}

$strSQL = "update `bet_Commission` set Commission = 97 where Bet_Type = 28 and Gamble_Type = 1";
PMA_mysql_query($strSQL, $_ConnMaster);
$strSQL = "update `bet_Commission` set Commission = 96 where Bet_Type = 28 and Gamble_Type = 2";
PMA_mysql_query($strSQL, $_ConnMaster);
$strSQL = "update `bet_Commission` set Commission = 95 where Bet_Type = 28 and Gamble_Type = 3";
PMA_mysql_query($strSQL, $_ConnMaster);
print "Commission OK! <br />\n";


$strSQL= "select * from `bet_MemberLimit` where Bet_Type = ".$intOldBT;
if(!$RS = @PMA_mysql_query($strSQL, $_ConnMaster)){
	$GLOBALS["errorhidden"] = "Find Data Error!";
	$GLOBALS["errorhidden"] = "SQL: ".$strSQL.", \nError: ".PMA_mysql_error($_ConnMaster).", \nLine: ".__LINE__.", \nPage: ".__FILE__;
	include($_SERVER["DOCUMENT_ROOT"]."/error.php");
	exit();
}

if(@PMA_mysql_num_rows($RS) == 0){
	$GLOBALS["errorhidden"] = "Can not Find Data!!";
	$GLOBALS["errorhidden"] = "SQL: ".$strSQL.", \n\nLine: ".__LINE__.", \nPage: ".__FILE__;
	include($_SERVER["DOCUMENT_ROOT"]."/error.php");
	exit();
}

while($Rows = PMA_mysql_fetch_object($RS)){
	$strSQL = "select ID from `bet_MemberLimit` where Bet_Type = ".$intNewBT." and MemID = ".$Rows -> MemID." and LimitType  = ".$Rows -> LimitType;
	if(!$subRS = @PMA_mysql_query($strSQL, $_ConnMaster)){
		$GLOBALS["errorhidden"] = "Find Data Error!";
		$GLOBALS["errorhidden"] = "SQL: ".$strSQL.", \nError: ".PMA_mysql_error($_ConnMaster).", \nLine: ".__LINE__.", \nPage: ".__FILE__;
		include($_SERVER["DOCUMENT_ROOT"]."/error.php");
		exit();
	}
	if(@PMA_mysql_num_rows($subRS) > 0)continue;
	$strSQL = "insert into `bet_MemberLimit`(Bet_Type, MemID, LimitType, LimitValue) values(".$intNewBT.", ".$Rows -> MemID.", ".$Rows -> LimitType.", '".$Rows -> LimitValue."')";
	PMA_mysql_query($strSQL, $_ConnMaster);
}

print "Limit OK! <br />\n";
?>